package com.project.basis.config

import android.app.Application
import com.project.basis.entity.LoginEntityMessage

class ProjectApplication : Application() {

    companion object {

        lateinit var context: ProjectApplication

        /**
         * 上一次点击事件
         */
        private var lastClickTime: Long = 0

        /**
         * 快速点击间隔时间
         */
        private val CLICK_TIME = 1000

        /**
         * 上次点击的View id
         */
        private var id = 0

        var loginEntity: LoginEntityMessage? = null

        fun isLogin(): Boolean {
            return loginEntity != null
        }

        // 判断按钮是否快速点击
        fun isFastClick(viewId: Int): Boolean {
            val time = System.currentTimeMillis()
            if (id == viewId && time - lastClickTime < CLICK_TIME) { // 判断点击的View相同并且系统时间差小于点击间隔时间
                return true
            }
            id = viewId
            lastClickTime = time
            return false
        }
    }

    override fun onCreate() {
        super.onCreate()
        context = this
    }
}